


import '../manger/app_info/app_info_manager.dart';

class EventEntity {
  static int count = 1;
  String eventName;

  late int eventFiringOrder;
  late int openBatchId;
  String appVersionCode = "";
  int? clientTimeLong;

  String pageName;
  int duration;
  int eventSource;

  EventEntity({
    required this.eventName,
    required this.openBatchId,
    this.pageName = "",
    this.duration = 0,
    this.eventSource = 0,
  }) {
    eventFiringOrder = count++;
    if (count > 10000000) {
      count = 1;
    }
    clientTimeLong = DateTime.now().millisecondsSinceEpoch;
  }

  Map<String, dynamic> toJson() {
    return {
      "eventName": eventName,
      "eventFiringOrder": eventFiringOrder,
      "openBatchId": openBatchId,
      "clientTimeLong": clientTimeLong,
      "pageName": pageName,
      "duration": duration,
      "appVersionCode": AppInfoManager().info.appBuildVersion,
      "eventSource": eventSource,
    };
  }
}
